/**   
* @Title: LoginIntecepter.java 
* @Package com.leesche.zcsp.node.web.intecepter 
* @Description:() 
* @author dennies yang
* @date 2016年9月27日 下午11:38:13 
* @version V1.0   
*/
package com.leesche.zcsp.node.web.intecepter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import com.leesche.zcsp.node.web.constants.Constants;
import com.leesche.zcsp.node.web.vo.Principal;





/**
 * @Title: LoginIntecepter.java
 * @Package com.leesche.zcsp.node.web.intecepter
 * @Description:()
 * @author dennies yang
 * @date 2016年9月27日 下午11:38:13
 * @version V1.0
 */
public class LoginIntecepter extends HandlerInterceptorAdapter {

	// 拦截后台登录界面
	public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
			ModelAndView modelAndView) throws Exception {

		// response.sendRedirect("/labour/weixin/login/index.jhtml");

	}

	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
			throws Exception {
		 Principal principal = (Principal)request.getSession().getAttribute(Constants.LOGIN_CURRENT_USER);
		    if (principal != null) {
		      return true;
		    }
		    if (request.getMethod().equalsIgnoreCase("GET")) {
		        response.sendRedirect("/node/index"); 
		    } 
		    return false;

	}
}
